#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
const int M=1e3;
int t,n,m,L,V,d[N],v[N],a[N],p[N],jii[N],ansa,ansb;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--)
    {
        cin>>n>>m>>L>>V;
        for(int i=0;i<n;i++)cin>>d[i]>>v[i]>>a[i];
        for(int i=0;i<m;i++)cin>>p[i];
        for(int i=0;i<n;i++)
        {
            int ji[N];
            for(int j=0;j<m;j++)
            {
                if(d[i]>p[j])
                {
                    continue;
                }
                else if(d[i]==p[j])
                {
                    if(v[i]>V)
                    {
                        ansa++;
                        ji[j]=1;
                        break;
                    }
                }
                else
                {
                    if(a!=0)
                    {
                        double sv=sqrt(v[i]*v[i]+2*a[i]*(p[j]-d[i]));
                        if(sv>V)
                        {
                            ansa++;
                            ji[j]=1;
                            break;
                        }
                    }
                    else if(a==0)
                    {
                        if(v[i]>V)
                        {
                            ansa++;
                            ji[j]=1;
                        }
                        break;
                    }
                }
            }
            for(int j=0;j<m-1;j++)
            {
                if(ji[i]==1&&ji[i+1]==1)jii[i]=0;
                else if(ji[i]==1&&ji[i+1]==0)jii[i]=1;
            }
        }
        for(int i=0;i<m;i++)
        {
            if(ji[i]==0)ansb++;
        }
        cout<<ansa<<" "<<ansb<<endl;
        ansa=0;
        ansb=0;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
